<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/common.css"/>
    <link rel="stylesheet" href="css/main.css"/>
    <link rel="stylesheet" href="css/jquery-ui-timepicker-addon.css"/>
    <link rel="stylesheet" href="css/jquery-ui.css"/>
    <link href="css/city-picker.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/jquery-impromptu.min.css" type="text/css"/>
    <title>借款申请</title>
</head>
<body>
<div class="container">
    <div id="dataLoad" style="display:none; position: fixed; width: 100%; top: 20%; z-index: 1001;">
           <table width=100% height=100% border=0 align=center valign=middle>
            <tr height=50%><td align=center>&nbsp;</td></tr>
            <tr><td align=center><img src="images/loading.gif"/></td></tr>
            <tr><td align=center>提交中，请稍后......</td></tr>
            <tr height=50%><td align=center>&nbsp;</td></tr>
           </table>
         </div>
    <div class="container">

        <div id="forms" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">借款申请信息</b></div>
                <div class="box_center">
                    <form action="" class="jqtransform">
                        <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                           <!-- <tr>
                                <td class="td_right">关联事件</td>
                                <td class="">
                                    <select name="" class="select" id="jiekuan-select">
                                        <option>无</option>
                                        <option>北京</option>
                                        <option>天津</option>
                                        <option>上海</option>
                                    </select>
                                      </td>
                            </tr>-->
                            <tr>
                                <td class="td_right">所属部门：</td>
                                <td class="">
                                    <input type="text" placeholder="请输入所属部门" class="input-text lh25" size="20" disabled id="loanMoney_depart">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">借款人：</td>
                                <td class="">
                                    <input type="text" placeholder="请输入人员姓名" class="input-text lh25" size="20" disabled id="loanMoney_user">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">借款事由：</td>
                                <td class="">
                                    <textarea name="" id="loanMoney_reason" cols="30" rows="10" class="textarea"></textarea>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">借款金额：</td>
                                <td class="">
                                    <input type="number" placeholder="请输入借款金额" class="input-text lh25" size="20" id="loanMoney_amount">
                                    <span></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">&nbsp;</td>
                                <td class="">
                                    <input type="button" id="confirm_btn" name="button" class="btn1 btn82 btn_save2" value="确定">
                                    <input type="button" id="reset_btn" name="button" class="btn1 btn82 btn_res" value="重置">
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/colResizable-1.6.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/datapicker_cn.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script src="js/city-picker.data.js"></script>
<script src="js/city-picker.js"></script>
<script src="js/main.js"></script>
<script src="js/config.js" type="text/javascript"></script>
<script src="js/jquery-impromptu.min.js" type="text/javascript"></script>

<script type="text/javascript">
    var loanMoneyData={};
    var isSetMoneyData = false;
    //辅助函数，处理借款审批的基本信息显示或修改
    function initLoanMoneyBasicInfo(){
        var curUser = JSON.parse(window.localStorage.getItem('user_info'));
        var curDepart = window.localStorage.getItem('cur_department');
        $('#loanMoney_depart').val(curUser.department_info[curDepart].department_name);
        $('#loanMoney_user').val(curUser.user_name);

        loanMoneyData.user_id = curUser.user_id;
        loanMoneyData.depart_id = curUser.department_info[curDepart].department_id;
        $('#loanMoney_reason').val('');
        $('#loanMoney_amount').val('');

    }
    //辅助函数，处理借款信息
    function processLoanMoneyData(){
        var reason = $('#loanMoney_reason').val();
        var money = $('#loanMoney_amount').val();
        if(reason == '' || money == '' || parseFloat(money) == 'NaN')
            return false;
        else{
            loanMoneyData.reason = reason;
            loanMoneyData.money = money;
            return true;
        }

    }



    //辅助函数，上传数据
    function uploadData(){
        $('#dataLoad').show();
        $.post(url + 'LoanFee/CreateLoanFeeApprove.php', loanMoneyData, function(data){

            var t = JSON.parse(data);
            $('#dataLoad').hide();
            if(t.state == 1){
                $.prompt( "<h3>提交成功，请耐心等待审批</h3>",{
                    title: '消息提醒',
                    buttons: {'确定': true},
                    submit: function(e, v, m, f){
                        if(v){
                            jumpPage('my_ordinary_loan_fee.html');
                        }
                    }
                });
            }
            else{
                $.prompt( "<h3>网络或数据库错误，请稍后再试</h3>",{
                    title: '错误提醒',
                    buttons: {'确定': true},
                });
            }
        });
    }
    //辅助函数，清空所有数据
    function clearData(){
        $('#loanMoney_depart').val('').change();
        $('#loanMoney_user').val('').change();
        $('#loanMoney_reason').val('').change();
        $('#loanMoney_amount').val('').change();
    }


    $(function(){
        $("#people_table").colResizable({
            liveDrag:true,
            gripInnerHtml:"<div class='grip'></div>",
            draggingClass:"dragging",
            resizeMode:'flex'
        });
        initLoanMoneyBasicInfo();




        //处理确定按钮
        $('#confirm_btn').click(function(){
            var r = processLoanMoneyData();
            if(!r){
                $.prompt( "<h4>未填写借款理由或借款金额填写错误</h4>",{
                    title: '错误提醒',
                    buttons: {'确定': true}
                });
            }
            else{
                uploadData();
            }



        });

        //处理重置按钮
        $('#reset_btn').click(function(){
            clearData();
        })
    });


</script>
</html>